﻿using System;

namespace KuiHuaBaoDian.Services.Battle.Entity {

    /// <summary>
    /// 战斗实体ID
    /// </summary>
    public readonly struct BattleEntityID {

        /// <summary>
        /// 空值
        /// </summary>
        public static readonly BattleEntityID Empty = new() { Type = default, SupplementID = 0 };

        /// <summary>
        /// 补充ID
        /// </summary>
        public int SupplementID { get; init; }

        /// <summary>
        /// 类型
        /// </summary>
        public BattleEntityType Type { get; init; }

        public override bool Equals(object obj) {
            if (obj is BattleEntityID other) {
                return Type == other.Type && SupplementID == other.SupplementID;
            }
            return false;
        }

        public override int GetHashCode() => HashCode.Combine(Type, SupplementID);

        public override string ToString() => $"[{nameof(BattleEntityID)}({nameof(Type)}={Type},{nameof(SupplementID)}={SupplementID})]";

        public static bool operator ==(BattleEntityID left, BattleEntityID right) => left.Equals(right);

        public static bool operator !=(BattleEntityID left, BattleEntityID right) => !left.Equals(right);
    }
}
